package com.ruoyi.web.controller.common;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.ruoyi.common.config.PreventionConfig;
import com.ruoyi.common.constant.GlobalConstants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.opio.util.ExampleBase;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.pdf.FileUtil;
import com.ruoyi.system.domain.SysDanger;
import com.ruoyi.system.entity.*;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.PreventionUnitStopItemService;
import com.ruoyi.system.service.SysDangerPointService;
import com.ruoyi.system.service.impl.SysDangerPointServiceImpl;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.apache.commons.io.FileUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;

@Slf4j
@RestController
@RequestMapping("/preventionPush")
public class PreventionPush {

    @Resource
    private PreventionSecurityRiskMapper preventionSecurityRiskMapper;

    @Resource
    private PreventionDeviceMapper preventionDeviceMapper;

    @Resource
    private PreventionCheckTaskConfigMapper preventionCheckTaskConfigMapper;

    @Resource
    private PreventionCheckTaskMapper preventionCheckTaskMapper;

    @Resource
    private SysDangerMapper sysDangerMapper;

    @Resource
    private ISysUserService sysUserService;

    @Resource
    private PreventionHiddenRegisterMapper preventionHiddenRegisterMapper;

    @Resource
    private PreventionHiddenInfoRecordMapper preventionHiddenInfoRecordMapper;

    @Resource
    private PushInfoMapper pushInfoMapper;

    @Resource
    private SysDutyUserMapper sysDutyUserMapper;

    @Resource
    private PreventionTaskNumMapper preventionTaskNumMapper;

    @Resource
    private PreventionUnitStopItemService preventionUnitStopItemService;

    @Resource
    private PreventionUnitMapper preventionUnitMapper;

    @Resource
    private SysDangerPointService sysDangerPointService;

    @Resource
    private SysDangerPointServiceImpl sysDangerPointServicei;
    /*

        000 - 风险分析单元ID
        001 - 风险分析事件ID
        002 - 风险分析管控措施ID
        003 - 排查任务配置ID
        004 - 排查任务记录ID
        005 - 隐患登记ID
        006 - 单元位置停用记录ID
        007 - 单元位置ID

     */

    /**
     * 推送风险分析单元
     *
     * @return
     */
    @GetMapping("/pushUnit")
    public AjaxResult pushUnit() {
        List<PreventionSecurityRisk> list = new ArrayList<>();
        List<PreventionDevice> preventionDevices = preventionDeviceMapper.queryAllByLimit(new PreventionDevice());
        for (PreventionDevice preventionDevice : preventionDevices) {
            List<PreventionSecurityRisk> all = preventionSecurityRiskMapper.queryAllUnit(preventionDevice.getId(), getBeginOfDay(), getEndOfDay());
            for (PreventionSecurityRisk securityRisk : all) {
                String dangerName = preventionDevice.getDangerName();
                SysDanger sysDanger = sysDangerMapper.queryByName(dangerName);
                if (null == sysDanger || StrUtil.isEmpty(sysDanger.getDangerCode())) {
                    continue;
                }
                securityRisk.setDangerCode(sysDanger.getDangerCode());
                list.add(securityRisk);
            }
        }

        String governId = null;
        String uuidString = null;
        PreventionSecurityRisk entity = null;
        List<JSONObject> data = new ArrayList<>();

//        List<String> uuid1 = new ArrayList<String>();
//        List<String> uuid2 = new ArrayList<String>();

        for (PreventionSecurityRisk preventionSecurityRisk : list) {
//            if (true) {
//                uuid1.add( enId(preventionSecurityRisk.getId().toString()) + "-000" );
//                governId = preventionSecurityRisk.getGovernId();
//                uuidString = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
//                entity = new PreventionSecurityRisk();
//                entity.setDeviceId(preventionSecurityRisk.getDeviceId());
//                entity.setAnalysisUnit(preventionSecurityRisk.getAnalysisUnit());
//                entity.setGovernId(uuidString);
//                preventionSecurityRiskMapper.updateGovernId(entity);
//                uuid2.add( uuidString );
//
//                continue;
//            }

            JSONObject obj = new JSONObject();

//            obj.put("id", enId(preventionSecurityRisk.getId().toString()) + "-000");
            governId = preventionSecurityRisk.getGovernId();
            uuidString = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
            entity = new PreventionSecurityRisk();
            entity.setDeviceId(preventionSecurityRisk.getDeviceId());
            entity.setAnalysisUnit(preventionSecurityRisk.getAnalysisUnit());
            entity.setGovernId(uuidString);
            preventionSecurityRiskMapper.updateGovernId(entity);
            obj.put("id", uuidString);

            obj.put("companyCode", GlobalConstants.COMPANY_CODE);
            obj.put("hazardCode", preventionSecurityRisk.getDangerCode());
            obj.put("riskUnitName", preventionSecurityRisk.getAnalysisUnit());
            obj.put("hazardDep", preventionSecurityRisk.getDeptName());
            obj.put("hazardLiablePerson", preventionSecurityRisk.getUserName());
            obj.put("deleted", "0");
            obj.put("createDate", LocalDateTimeUtil.format(preventionSecurityRisk.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("createBy", preventionSecurityRisk.getCreateBy());
            obj.put("updateDate", LocalDateTimeUtil.format(preventionSecurityRisk.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("updateBy", preventionSecurityRisk.getUpdateBy());
            data.add(obj);
        }

//        log.error("------------推送风险分析单元-----------------开始");
//        log.error("历史主键：");
//        uuid1.forEach(System.out::println);
//        log.error("最新主键：");
//        uuid2.forEach(System.out::println);
//        log.error("------------推送风险分析单元-----------------结束");

        String url = PreventionConfig.unit;
        String s = PreventionConfig.pushData(JSONUtil.toJsonPrettyStr(data), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }

    @GetMapping("/pushUnitJT")
    public AjaxResult pushUnitJT() {
        List<PreventionSecurityRisk> list = new ArrayList<>();
        List<PreventionDevice> preventionDevices = preventionDeviceMapper.queryAllByLimit(new PreventionDevice());
        for (PreventionDevice preventionDevice : preventionDevices) {
            List<PreventionSecurityRisk> all = preventionSecurityRiskMapper.queryAllUnit(preventionDevice.getId(), getBeginOfDay(), getEndOfDay());
            for (PreventionSecurityRisk securityRisk : all) {
                String dangerName = preventionDevice.getDangerName();
                SysDanger sysDanger = sysDangerMapper.queryByName(dangerName);
                if (null == sysDanger || StrUtil.isEmpty(sysDanger.getDangerCode())) {
                    continue;
                }
                securityRisk.setDangerCode(sysDanger.getDangerCode());
                list.add(securityRisk);
            }
        }

        Map<String, Object> sendMap = new HashMap<>();
        sendMap.put("APPID", "1332");
        sendMap.put("REPORTCOMPANY", "石洞口煤气");
        sendMap.put("REPORTDATE", new DateTime());
        sendMap.put("REPORTMODULE", "AQGL_AQFXFXDY");
        sendMap.put("REPORTTYPE", "双重预防机制");
        List<JSONObject> data = new ArrayList<>();
        for (PreventionSecurityRisk preventionSecurityRisk : list) {
            JSONObject obj = new JSONObject();
            UUID uuid = UUID.randomUUID();
            String uuidString = uuid.toString();
            obj.put("ID", uuidString);
            obj.put("REPORTMODULE", "双重预防机制");
            obj.put("REPORTTYPE", "安全风险分析单元");
            obj.put("COMPANYCODE", GlobalConstants.COMPANY_CODE);
            obj.put("HAZARDCODE", preventionSecurityRisk.getDangerCode());
            obj.put("HAZARDDEP", preventionSecurityRisk.getDeptName());
            obj.put("HAZARDLIABLEPERSON", preventionSecurityRisk.getUserName());
            obj.put("RISKUNITNAME", preventionSecurityRisk.getAnalysisUnit());
            obj.put("DELETED", "0");
            obj.put("CREATEDATE", LocalDateTimeUtil.format(preventionSecurityRisk.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("CREATEBY", preventionSecurityRisk.getCreateBy());
            obj.put("UPDATEDATE", LocalDateTimeUtil.format(preventionSecurityRisk.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("UPDATEBY", preventionSecurityRisk.getUpdateBy());
            data.add(obj);
        }
        sendMap.put("REPORTCONTENT", data);

        String url = PreventionConfig.unitJT;
        String s = PreventionConfig.pushDataJT(JSONUtil.toJsonPrettyStr(sendMap), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }

    /**
     * 推送风险分析单元停用记录
     *
     * @return
     */
    @GetMapping("/pushUnitStop")
    public AjaxResult pushUnitStop() {

        String uuidString = null;
        String uuidString2 = null;
        PreventionUnit unitEntity = null;
        PreventionUnitStopItem entity = null;
        List<PreventionUnitStopItem> preventionUnitStopItems = preventionUnitStopItemService.queryAll(getBeginOfDay(), getEndOfDay());
        List<JSONObject> data = new ArrayList<>();

//        List<String> uuid1 = new ArrayList<String>();
//        List<String> uuid2 = new ArrayList<String>();
//
//        List<String> uuid3 = new ArrayList<String>();
//        List<String> uuid4 = new ArrayList<String>();


        for (PreventionUnitStopItem preventionUnitStopItem : preventionUnitStopItems) {
            Integer unitId = preventionUnitStopItem.getUnitId();
            PreventionUnit preventionUnit = preventionUnitMapper.queryById(unitId);
            Integer deviceId = preventionUnit.getDeviceId();
            PreventionDevice preventionDevice = preventionDeviceMapper.queryById(deviceId);
            if (null == preventionDevice) {
                continue;
            }
            String dangerName = preventionDevice.getDangerName();
            SysDanger sysDanger = sysDangerMapper.queryByName(dangerName);
            if (null == sysDanger || StrUtil.isEmpty(sysDanger.getDangerCode())) {
                continue;
            }
            JSONObject obj = new JSONObject();

//            if (true) {
//                uuid1.add( enId(preventionUnitStopItem.getId().toString()) + "-006" );
//                String governId = preventionUnitStopItem.getGovernId();
//                String uuidString = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
//                entity = new PreventionUnitStopItem();
//                entity.setId(preventionUnitStopItem.getId());
//                entity.setGovernId(uuidString);
//                preventionUnitStopItemService.update(entity);
//                uuid2.add( uuidString );
//
//                uuid3.add( enId(preventionUnitStopItem.getUnitId().toString()) + "-000" );
//                governId = preventionUnit.getGovernId();
//                String uuidString2 = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
//                unitEntity = new PreventionUnit();
//                unitEntity.setGovernId(uuidString2);
//                unitEntity.setId(unitId);
//                preventionUnitMapper.update(unitEntity);
//                uuid4.add( uuidString2 );
//
//                continue;
//            }



//            obj.put("id", enId(preventionUnitStopItem.getId().toString()) + "-006");
            String governId = preventionUnitStopItem.getGovernId();
            uuidString = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
            entity = new PreventionUnitStopItem();
            entity.setId(preventionUnitStopItem.getId());
            entity.setGovernId(uuidString);
            preventionUnitStopItemService.update(entity);
            obj.put("id", uuidString);

            obj.put("companyCode", GlobalConstants.COMPANY_CODE);
            obj.put("hazardCode", sysDanger.getDangerCode());

//            obj.put("riskUnitId", enId(preventionUnitStopItem.getUnitId().toString()) + "-000");
            governId = preventionUnit.getGovernId();
            uuidString2 = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
            unitEntity = new PreventionUnit();
            unitEntity.setGovernId(uuidString2);
            unitEntity.setId(unitId);
            preventionUnitMapper.update(unitEntity);
            obj.put("riskUnitId", uuidString2);

            obj.put("stopStartTime", preventionUnitStopItem.getStartTime());
            obj.put("stopEndTime", preventionUnitStopItem.getStopTime());
            obj.put("stopReason", preventionUnitStopItem.getStopInfo());
            obj.put("createDate", LocalDateTimeUtil.format(preventionUnitStopItem.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("createBy", preventionUnitStopItem.getCreateUser());
            obj.put("updateBy", preventionUnitStopItem.getUpdateUser());
            obj.put("updateDate", LocalDateTimeUtil.format(preventionUnitStopItem.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("createByMobile", "/");
            data.add(obj);
        }

//        log.error("------------推送风险分析单元停用记录-----------------开始");
//        log.error("历史主键：");
//        uuid1.forEach(System.out::println);
//        log.error("最新主键：");
//        uuid2.forEach(System.out::println);
//
//        log.error("--------------");
//        log.error("riskUnitId历史：");
//        uuid3.forEach(System.out::println);
//        log.error("riskUnitId最新：");
//        uuid4.forEach(System.out::println);
//        log.error("------------推送风险分析单元停用记录-----------------结束");

        String url = PreventionConfig.unitStop;
        String s = PreventionConfig.pushData(JSONUtil.toJsonPrettyStr(data), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }


    @GetMapping("/pushUnitStopJT")
    public AjaxResult pushUnitStopJT() {
        List<PreventionUnitStopItem> preventionUnitStopItems = preventionUnitStopItemService.queryAll(getBeginOfDay(), getEndOfDay());
        List<JSONObject> data = new ArrayList<>();

        Map<String, Object> sendMap = new HashMap<>();
        sendMap.put("APPID", "1332");
        sendMap.put("REPORTCOMPANY", "石洞口煤气");
        sendMap.put("REPORTDATE", new DateTime());
        sendMap.put("REPORTMODULE", "AQGL_ZZTYJWXJL");
        sendMap.put("REPORTTYPE", "双重预防机制");

        for (PreventionUnitStopItem preventionUnitStopItem : preventionUnitStopItems) {

            log.info("推送双重预防机制停工数据:{}", JSONUtil.toJsonStr(preventionUnitStopItem));

            Integer unitId = preventionUnitStopItem.getUnitId();
            PreventionUnit preventionUnit = preventionUnitMapper.queryById(unitId);
            Integer deviceId = preventionUnit.getDeviceId();
            PreventionDevice preventionDevice = preventionDeviceMapper.queryById(deviceId);
            if (null == preventionDevice) {
                continue;
            }
            String dangerName = preventionDevice.getDangerName();
            SysDanger sysDanger = sysDangerMapper.queryByName(dangerName);
            if (null == sysDanger || StrUtil.isEmpty(sysDanger.getDangerCode())) {
                continue;
            }
            JSONObject obj = new JSONObject();
            UUID uuid = UUID.randomUUID();
            String uuidString = uuid.toString();
            obj.put("ID", uuidString);
            obj.put("COMPANYCODE", GlobalConstants.COMPANY_CODE);
            obj.put("HAZARDCODE", sysDanger.getDangerCode());
            obj.put("RISKUNITID", enId(preventionUnitStopItem.getUnitId().toString()) + "-000");
            obj.put("STOPSTARTTIME", preventionUnitStopItem.getStartTime());
            obj.put("STOPENDTIME", preventionUnitStopItem.getStopTime());
            obj.put("STOPREASON", preventionUnitStopItem.getStopInfo());
            obj.put("CREATEDATE", LocalDateTimeUtil.format(preventionUnitStopItem.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("CREATEBY", preventionUnitStopItem.getCreateUser());
            obj.put("UPDATEBY", preventionUnitStopItem.getUpdateUser());
            obj.put("UPDATEDATE", LocalDateTimeUtil.format(preventionUnitStopItem.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("CREATEBYMOBILE", "/");
            data.add(obj);
        }
        sendMap.put("REPORTCONTENT", data);

        String url = PreventionConfig.unitJT;
        String s = PreventionConfig.pushDataJT(JSONUtil.toJsonPrettyStr(sendMap), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }


    /**
     * 推送风险分析事件
     *
     * @return
     */
    @GetMapping("/pushEvent")
    public AjaxResult pushEvent() {
        PreventionSecurityRisk entity = null;
        List<JSONObject> data = new ArrayList<>();
        List<PreventionDevice> preventionDevices = preventionDeviceMapper.queryAllByLimit(new PreventionDevice());
//        List<String> uuid1 = new ArrayList<String>();
//        List<String> uuid2 = new ArrayList<String>();
//
//        List<String> uuid3 = new ArrayList<String>();
//        List<String> uuid4 = new ArrayList<String>();


        for (PreventionDevice preventionDevice : preventionDevices) {
            List<PreventionSecurityRisk> all = preventionSecurityRiskMapper.queryAllUnit(preventionDevice.getId(), getBeginOfDay(), getEndOfDay());
            if (CollUtil.isNotEmpty(all)) {
                for (PreventionSecurityRisk p : all) {
                    String analysisUnit = p.getAnalysisUnit();
                    List<PreventionSecurityRisk> list = preventionSecurityRiskMapper.queryAllEvent(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), analysisUnit);
                    for (PreventionSecurityRisk preventionSecurityRisk : list) {
                        JSONObject obj = new JSONObject();

//                        if (true) {
//                            uuid1.add( enId(preventionSecurityRisk.getId().toString()) + "-001" );
//                            String eventGovernId = preventionSecurityRisk.getEventGovernId();
//                            String uuidString = StringUtils.isEmpty(eventGovernId) ? UUID.randomUUID().toString() : eventGovernId;
//                            entity = new PreventionSecurityRisk();
//                            entity.setDeviceId(preventionSecurityRisk.getDeviceId());
//                            entity.setAnalysisUnit(preventionSecurityRisk.getAnalysisUnit());
//                            entity.setDangerEvent(preventionSecurityRisk.getDangerEvent());
//                            entity.setEventGovernId(uuidString);
//                            preventionSecurityRiskMapper.updateGovernId(entity);
//                            uuid2.add(uuidString);
//
//                            uuid3.add( enId(p.getId().toString()) + "-000" );
//                            String uuidString2 = StringUtils.isEmpty(p.getGovernId()) ? UUID.randomUUID().toString() : p.getGovernId();
//                            entity = new PreventionSecurityRisk();
//                            entity.setDeviceId(preventionSecurityRisk.getDeviceId());
//                            entity.setAnalysisUnit(preventionSecurityRisk.getAnalysisUnit());
//                            entity.setGovernId(uuidString2);
//                            preventionSecurityRiskMapper.updateGovernId(entity);
//                            uuid4.add( uuidString2 );
//
//                            continue;
//                        }


//                        obj.put("id", enId(preventionSecurityRisk.getId().toString()) + "-001");
                        String eventGovernId = preventionSecurityRisk.getEventGovernId();
                        String uuidString = StringUtils.isEmpty(eventGovernId) ? UUID.randomUUID().toString() : eventGovernId;
                        entity = new PreventionSecurityRisk();
                        entity.setDeviceId(preventionSecurityRisk.getDeviceId());
                        entity.setAnalysisUnit(preventionSecurityRisk.getAnalysisUnit());
                        entity.setDangerEvent(preventionSecurityRisk.getDangerEvent());
                        entity.setEventGovernId(uuidString);
                        preventionSecurityRiskMapper.updateGovernId(entity);
                        obj.put("id", uuidString);

                        obj.put("companyCode", GlobalConstants.COMPANY_CODE);

//                        obj.put("riskUnitId", enId(p.getId().toString()) + "-000");
                        String uuidString2 = StringUtils.isEmpty(p.getGovernId()) ? UUID.randomUUID().toString() : p.getGovernId();
                        entity = new PreventionSecurityRisk();
                        entity.setDeviceId(preventionSecurityRisk.getDeviceId());
                        entity.setAnalysisUnit(preventionSecurityRisk.getAnalysisUnit());
                        entity.setGovernId(uuidString2);
                        preventionSecurityRiskMapper.updateGovernId(entity);
                        obj.put("riskUnitId", uuidString2);

                        obj.put("riskEventName", preventionSecurityRisk.getDangerEvent());
                        obj.put("deleted", "0");
                        obj.put("createDate", LocalDateTimeUtil.format(preventionSecurityRisk.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                        obj.put("createBy", preventionSecurityRisk.getCreateBy());
                        obj.put("updateDate", LocalDateTimeUtil.format(preventionSecurityRisk.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
                        obj.put("updateBy", preventionSecurityRisk.getUpdateBy());
                        data.add(obj);
                    }
                }
            }
        }
//        log.error("------------推送风险分析事件-----------------开始");
//        log.error("历史主键：");
//        uuid1.forEach(System.out::println);
//        log.error("最新主键：");
//        uuid2.forEach(System.out::println);
//
//        log.error("--------------");
//
//        log.error("riskUnitId历史：");
//        uuid3.forEach(System.out::println);
//        log.error("riskUnitId最新：");
//        uuid4.forEach(System.out::println);
//        log.error("------------推送风险分析事件-----------------结束");

        String url = PreventionConfig.event;
        String s = PreventionConfig.pushData(JSONUtil.toJsonPrettyStr(data), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }

    /**
     * 推送风险分析事件
     *
     * @return
     */
    @GetMapping("/pushEventJT")
    public AjaxResult pushEventJT() {
        Map<String, Object> sendMap = new HashMap<>();
        sendMap.put("APPID", "1332");
        sendMap.put("REPORTCOMPANY", "石洞口煤气");
        sendMap.put("REPORTDATE", new DateTime());
        sendMap.put("REPORTMODULE", "AQGL_AQFXSJ");
        sendMap.put("REPORTTYPE", "双重预防机制");

        List<JSONObject> data = new ArrayList<>();
        List<PreventionDevice> preventionDevices = preventionDeviceMapper.queryAllByLimit(new PreventionDevice());
        for (PreventionDevice preventionDevice : preventionDevices) {
            List<PreventionSecurityRisk> all = preventionSecurityRiskMapper.queryAllUnit(preventionDevice.getId(), getBeginOfDay(), getEndOfDay());
            if (CollUtil.isNotEmpty(all)) {
                for (PreventionSecurityRisk p : all) {
                    String analysisUnit = p.getAnalysisUnit();
                    List<PreventionSecurityRisk> list = preventionSecurityRiskMapper.queryAllEvent(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), analysisUnit);
                    for (PreventionSecurityRisk preventionSecurityRisk : list) {
                        JSONObject obj = new JSONObject();
                        UUID uuid = UUID.randomUUID();
                        String uuidString = uuid.toString();
                        obj.put("ID", uuidString);
                        obj.put("REPORTMODULE", "双重预防机制");
                        obj.put("REPORTTYPE", "安全风险事件");
                        obj.put("COMPANYCODE", GlobalConstants.COMPANY_CODE);
                        obj.put("RISKUNITID", enId(p.getId().toString()) + "-000");
                        obj.put("RISKEVENTNAME", preventionSecurityRisk.getDangerEvent());
                        obj.put("DELETED", "0");
                        obj.put("CREATEDATE", LocalDateTimeUtil.format(preventionSecurityRisk.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                        obj.put("CREATEBY", preventionSecurityRisk.getCreateBy());
                        obj.put("UPDATEDATE", LocalDateTimeUtil.format(preventionSecurityRisk.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
                        obj.put("UPDATEBY", preventionSecurityRisk.getUpdateBy());
                        data.add(obj);
                    }
                }
            }
        }

        sendMap.put("REPORTCONTENT", data);

        String url = PreventionConfig.unitJT;
        String s = PreventionConfig.pushDataJT(JSONUtil.toJsonPrettyStr(sendMap), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }

    /**
     * 推送安全风险管控
     *
     * @return
     */
    @GetMapping("/pushControl")
    public AjaxResult pushControl() {
        PreventionSecurityRisk entity = null;
        List<JSONObject> data = new ArrayList<>();
        List<PreventionDevice> preventionDevices = preventionDeviceMapper.queryAllByLimit(new PreventionDevice());

//        List<String> uuid1 = new ArrayList<String>();
//        List<String> uuid2 = new ArrayList<String>();
//
//        List<String> uuid3 = new ArrayList<String>();
//        List<String> uuid4 = new ArrayList<String>();

        for (PreventionDevice preventionDevice : preventionDevices) {
            List<PreventionSecurityRisk> all = preventionSecurityRiskMapper.queryAllUnit(preventionDevice.getId(), getBeginOfDay(), getEndOfDay());
            if (CollUtil.isNotEmpty(all)) {
                for (PreventionSecurityRisk p : all) {
                    String analysisUnit = p.getAnalysisUnit();
                    List<PreventionSecurityRisk> events = preventionSecurityRiskMapper.queryAllEvent(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), analysisUnit);
                    for (PreventionSecurityRisk event : events) {
                        String dangerEvent = event.getDangerEvent();
                        List<PreventionSecurityRisk> list = preventionSecurityRiskMapper.queryAllControl(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), dangerEvent);
                        for (PreventionSecurityRisk preventionSecurityRisk : list) {
//                            if (true) {
//                                uuid1.add( enId(preventionSecurityRisk.getId().toString()) +   "-002" );
//                                String controlGovernId = preventionSecurityRisk.getControlGovernId();
//                                String uuidString = StringUtils.isEmpty(controlGovernId) ? UUID.randomUUID().toString() : controlGovernId;
//                                entity = new PreventionSecurityRisk();
//                                entity.setDeviceId(preventionSecurityRisk.getDeviceId());
//                                entity.setAnalysisUnit(preventionSecurityRisk.getAnalysisUnit());
//                                entity.setDangerEvent(preventionSecurityRisk.getDangerEvent());
//                                entity.setControlMeasures(preventionSecurityRisk.getControlMeasures());
//                                entity.setControlGovernId(uuidString);
//                                preventionSecurityRiskMapper.updateGovernId(entity);
//                                uuid2.add( uuidString );
//
//                                uuid3.add( enId(event.getId().toString()) + "-001" );
//                                String eventGovernId = event.getEventGovernId();
//                                String uuidString2 = StringUtils.isEmpty(eventGovernId) ? UUID.randomUUID().toString() : eventGovernId;
//                                entity = new PreventionSecurityRisk();
//                                entity.setDeviceId(event.getDeviceId());
//                                entity.setAnalysisUnit(event.getAnalysisUnit());
//                                entity.setDangerEvent(event.getDangerEvent());
//                                entity.setEventGovernId(uuidString2);
//                                preventionSecurityRiskMapper.updateGovernId(entity);
//                                uuid4.add( uuidString2 );
//
//                                continue;
//                            }


                            JSONObject obj = new JSONObject();
//                            obj.put("id", enId(preventionSecurityRisk.getId().toString()) +   "-002");
                            String controlGovernId = preventionSecurityRisk.getControlGovernId();
                            String uuidString = StringUtils.isEmpty(controlGovernId) ? UUID.randomUUID().toString() : controlGovernId;
                            entity = new PreventionSecurityRisk();
                            entity.setDeviceId(preventionSecurityRisk.getDeviceId());
                            entity.setAnalysisUnit(preventionSecurityRisk.getAnalysisUnit());
                            entity.setDangerEvent(preventionSecurityRisk.getDangerEvent());
                            entity.setControlMeasures(preventionSecurityRisk.getControlMeasures());
                            entity.setControlGovernId(uuidString);
                            preventionSecurityRiskMapper.updateGovernId(entity);
                            obj.put("id", uuidString);

                            obj.put("companyCode", GlobalConstants.COMPANY_CODE);

//                            obj.put("riskEventId", enId(event.getId().toString()) + "-001");
                            String eventGovernId = event.getEventGovernId();
                            String uuidString2 = StringUtils.isEmpty(eventGovernId) ? UUID.randomUUID().toString() : eventGovernId;
                            entity = new PreventionSecurityRisk();
                            entity.setDeviceId(event.getDeviceId());
                            entity.setAnalysisUnit(event.getAnalysisUnit());
                            entity.setDangerEvent(event.getDangerEvent());
                            entity.setEventGovernId(uuidString2);
                            preventionSecurityRiskMapper.updateGovernId(entity);
                            obj.put("riskEventId", uuidString2);

                            obj.put("dataSrc", preventionSecurityRisk.getControlType()==null ? "2" : preventionSecurityRisk.getControlType());
                            obj.put("riskMeasureDesc", preventionSecurityRisk.getControlMeasures());
                            obj.put("troubleshootContent", preventionSecurityRisk.getHiddenContent());
                            obj.put("classify1", measiresOne(preventionSecurityRisk.getMeasuresOne()).equals("0") ? "1" : measiresOne(preventionSecurityRisk.getMeasuresOne()));
                            obj.put("classify2", measiresTwo(preventionSecurityRisk.getMeasuresTwo(), preventionSecurityRisk.getMeasuresOne()).equals("0") ? "1-5" : measiresTwo(preventionSecurityRisk.getMeasuresTwo(), preventionSecurityRisk.getMeasuresOne()));
                            obj.put("classify3", preventionSecurityRisk.getMeasuresThree());
                            obj.put("deleted", "0");
                            obj.put("createDate", LocalDateTimeUtil.format(preventionSecurityRisk.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                            obj.put("createBy", preventionSecurityRisk.getCreateBy());
                            obj.put("updateDate", LocalDateTimeUtil.format(preventionSecurityRisk.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
                            obj.put("updateBy", preventionSecurityRisk.getUpdateBy());
                            data.add(obj);
                        }
                    }
                }
            }
        }

//        log.error("------------推送安全风险管控-----------------开始");
//        log.error("历史主键：");
//        uuid1.forEach(System.out::println);
//        log.error("最新主键：");
//        uuid2.forEach(System.out::println);
//
//        log.error("--------------");
//
//        log.error("riskEventId历史：");
//        uuid3.forEach(System.out::println);
//        log.error("riskEventId最新：");
//        uuid4.forEach(System.out::println);
//        log.error("------------推送安全风险管控-----------------结束");

        String url = PreventionConfig.control;
        String s = PreventionConfig.pushData(JSONUtil.toJsonPrettyStr(data), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }

    /**
     * 推送安全风险管控
     *
     * @return
     */
    @GetMapping("/pushControlJT")
    public AjaxResult pushControlJT() {
        Map<String, Object> sendMap = new HashMap<>();
        sendMap.put("APPID", "1332");
        sendMap.put("REPORTCOMPANY", "石洞口煤气");
        sendMap.put("REPORTDATE", new DateTime());
        sendMap.put("REPORTMODULE", "AQGL_AQFXGKCSXX");
        sendMap.put("REPORTTYPE", "双重预防机制");

        List<JSONObject> data = new ArrayList<>();
        List<PreventionDevice> preventionDevices = preventionDeviceMapper.queryAllByLimit(new PreventionDevice());
        for (PreventionDevice preventionDevice : preventionDevices) {
            List<PreventionSecurityRisk> all = preventionSecurityRiskMapper.queryAllUnit(preventionDevice.getId(), getBeginOfDay(), getEndOfDay());
            if (CollUtil.isNotEmpty(all)) {
                for (PreventionSecurityRisk p : all) {
                    String analysisUnit = p.getAnalysisUnit();
                    List<PreventionSecurityRisk> events = preventionSecurityRiskMapper.queryAllEvent(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), analysisUnit);
                    for (PreventionSecurityRisk event : events) {
                        String dangerEvent = event.getDangerEvent();
                        List<PreventionSecurityRisk> list = preventionSecurityRiskMapper.queryAllControl(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), dangerEvent);
                        for (PreventionSecurityRisk preventionSecurityRisk : list) {
                            JSONObject obj = new JSONObject();
                            UUID uuid = UUID.randomUUID();
                            String uuidString = uuid.toString();
                            obj.put("ID", uuidString);
                            obj.put("COMPANYCODE", GlobalConstants.COMPANY_CODE);
                            obj.put("RISKEVENTID", enId(event.getId().toString()) + "-001");
                            obj.put("DATASRC", "2");
                            obj.put("RISKMEASUREDESC", preventionSecurityRisk.getControlMeasures());
                            obj.put("TROUBLESHOOTCONTENT", preventionSecurityRisk.getHiddenContent());
                            obj.put("CLASSIFY1", measiresOne(preventionSecurityRisk.getMeasuresOne()).equals("0") ? "1" : measiresOne(preventionSecurityRisk.getMeasuresOne()));
                            obj.put("CLASSIFY2", measiresTwo(preventionSecurityRisk.getMeasuresTwo(), preventionSecurityRisk.getMeasuresOne()).equals("0") ? "1-5" : measiresTwo(preventionSecurityRisk.getMeasuresTwo(), preventionSecurityRisk.getMeasuresOne()));
                            obj.put("CLASSIFY3", preventionSecurityRisk.getMeasuresThree());
                            obj.put("DELETED", "0");
                            obj.put("CREATEDATE", LocalDateTimeUtil.format(preventionSecurityRisk.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                            obj.put("CREATEBY", preventionSecurityRisk.getCreateBy());
                            obj.put("UPDATEDATE", LocalDateTimeUtil.format(preventionSecurityRisk.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
                            obj.put("UPDATEBY", preventionSecurityRisk.getUpdateBy());
                            data.add(obj);
                        }
                    }
                }
            }
        }
        sendMap.put("REPORTCONTENT", data);

        String url = PreventionConfig.unitJT;
        String s = PreventionConfig.pushDataJT(JSONUtil.toJsonPrettyStr(sendMap), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }

    public String measiresOne(String measiresOne) {
        switch (measiresOne) {
            case "工程技术":
                return "1";
            case "维护保养":
                return "2";
            case "操作行为":
                return "3";
            case "应急措施":
                return "4";
            default:
                return "0";
        }
    }

    public String measiresTwo(String measiresTwo, String measiresOne) {
        switch (measiresTwo) {
            case "工艺控制":
                return "1-1";
            case "关键设备/部件":
                return "1-2";
            case "安全附件":
                return "1-3";
            case "安全仪表":
                return "1-4";
            case "其它":
                if (measiresOne.equals("工程技术")) {
                    return "1-5";
                }
                if (measiresOne.equals("维护保养")) {
                    return "2-3";
                }
                if (measiresOne.equals("操作行为")) {
                    return "3-4";
                }
                if (measiresOne.equals("应急设施")) {
                    return "4-5";
                }
            case "动设备":
                return "2-1";
            case "静设备":
                return "2-2";
            case "人员资质":
                return "3-1";
            case "操作记录":
                return "3-2";
            case "交接班":
                return "3-3";
            case "应急设施":
                return "4-1";
            case "个体防护":
                return "4-2";
            case "消防设施":
                return "4-3";
            case "应急预案":
                return "4-4";
            default:
                return "0";
        }
    }

    // TODO 改

    /**
     * 推送隐患排查任务配置
     *
     * @return
     */
    @GetMapping("/pushTaskConfig")
    public AjaxResult pushTaskConfig() {
        List<JSONObject> data = new ArrayList<>();
        PreventionSecurityRisk entity = null;
        PreventionCheckTaskConfig configEntity = null;
        List<PreventionDevice> preventionDevices = preventionDeviceMapper.queryAllByLimit(new PreventionDevice());

//        List<String> uuid1 = new ArrayList<String>();
//        List<String> uuid2 = new ArrayList<String>();
//
//        List<String> uuid3 = new ArrayList<String>();
//        List<String> uuid4 = new ArrayList<String>();

        for (PreventionDevice preventionDevice : preventionDevices) {
            List<PreventionSecurityRisk> all = preventionSecurityRiskMapper.queryAllUnit(preventionDevice.getId(), getBeginOfDay(), getEndOfDay());
            if (CollUtil.isNotEmpty(all)) {
                for (PreventionSecurityRisk p : all) {
                    String analysisUnit = p.getAnalysisUnit();
                    List<PreventionSecurityRisk> events = preventionSecurityRiskMapper.queryAllEvent(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), analysisUnit);
                    for (PreventionSecurityRisk event : events) {
                        String dangerEvent = event.getDangerEvent();
                        List<PreventionSecurityRisk> controls = preventionSecurityRiskMapper.queryAllControl(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), dangerEvent);
                        for (PreventionSecurityRisk control : controls) {
                            String controlMeasures = control.getControlMeasures();
                            List<PreventionSecurityRisk> list = preventionSecurityRiskMapper.queryAllSecurityRisk(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), controlMeasures);
                            for (PreventionSecurityRisk preventionSecurityRisk : list) {
                                List<PreventionCheckTaskConfig> preventionCheckTaskConfigs = preventionCheckTaskConfigMapper.querySecurityRiskId(preventionSecurityRisk.getId());
                                if (CollUtil.isEmpty(preventionCheckTaskConfigs)) {
                                    continue;
                                }
                                PreventionCheckTaskConfig preventionCheckTaskConfig = preventionCheckTaskConfigs.get(0);
                                JSONObject obj = new JSONObject();

//                                if (true) {
//                                    uuid1.add( enId(preventionCheckTaskConfig.getId().toString()) + "-003" );
//                                    String governId = preventionCheckTaskConfig.getGovernId();
//                                    String uuidString = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
//                                    configEntity = new PreventionCheckTaskConfig();
//                                    configEntity.setGovernId(uuidString);
//                                    configEntity.setId(preventionCheckTaskConfig.getId());
//                                    preventionCheckTaskConfigMapper.update(configEntity);
//                                    uuid2.add( uuidString );
//
//                                    uuid3.add( enId(control.getId().toString()) + "-002" );
//                                    String controlGovernId = control.getControlGovernId();
//                                    String uuidString2 = StringUtils.isEmpty(controlGovernId) ? UUID.randomUUID().toString() : controlGovernId;
//                                    entity = new PreventionSecurityRisk();
//                                    entity.setDeviceId(control.getDeviceId());
//                                    entity.setAnalysisUnit(control.getAnalysisUnit());
//                                    entity.setDangerEvent(control.getDangerEvent());
//                                    entity.setControlMeasures(control.getControlMeasures());
//                                    entity.setControlGovernId(uuidString2);
//                                    preventionSecurityRiskMapper.updateGovernId(entity);
//                                    uuid4.add( uuidString2 );
//
//                                    continue;
//                                }

//                                obj.put("id", enId(preventionCheckTaskConfig.getId().toString()) + "-003");
                                String governId = preventionCheckTaskConfig.getGovernId();
                                String uuidString = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
                                configEntity = new PreventionCheckTaskConfig();
                                configEntity.setGovernId(uuidString);
                                configEntity.setId(preventionCheckTaskConfig.getId());
                                preventionCheckTaskConfigMapper.update(configEntity);
                                obj.put("id", uuidString);

                                obj.put("companyCode", GlobalConstants.COMPANY_CODE);

//                                obj.put("riskMeasureId", enId(control.getId().toString()) + "-002");
                                String controlGovernId = control.getControlGovernId();
                                String uuidString2 = StringUtils.isEmpty(controlGovernId) ? UUID.randomUUID().toString() : controlGovernId;
                                entity = new PreventionSecurityRisk();
                                entity.setDeviceId(control.getDeviceId());
                                entity.setAnalysisUnit(control.getAnalysisUnit());
                                entity.setDangerEvent(control.getDangerEvent());
                                entity.setControlMeasures(control.getControlMeasures());
                                entity.setControlGovernId(uuidString2);
                                preventionSecurityRiskMapper.updateGovernId(entity);
                                obj.put("riskMeasureId", uuidString2);

                                obj.put("hiddentRoubleDescription", preventionSecurityRisk.getHiddenContent());
                                obj.put("postPersonCharge", preventionSecurityRisk.getDeptUserName());
                                obj.put("checkCycle", preventionSecurityRisk.getCycle());
                                obj.put("checkCycleUnit", preventionSecurityRisk.getUnit().equals("日") ? "天" : preventionSecurityRisk.getUnit());
                                if (preventionSecurityRisk.getUnit().equals("小时")) {
                                    obj.put("workStartTime", getWorkTime(preventionCheckTaskConfig.getTaskStartTime()));
                                    obj.put("workEndTime", getWorkTime(preventionCheckTaskConfig.getTaskStartTime()));
                                }
                                obj.put("workType", preventionSecurityRisk.getDutyTask().equals("1") ? preventionSecurityRisk.getTaskDuty() : "0");
                                if (!obj.getString("workType").equals("0")) {
                                    PreventionTaskNum preventionTaskNum = preventionTaskNumMapper.queryById(preventionSecurityRisk.getTaskNumId());
                                    if (null == preventionTaskNum) {
                                        continue;
                                    }
                                    obj.put("taskNum", preventionTaskNum.getTaskNum());
                                }
                                obj.put("workCalendar", preventionSecurityRisk.getTaskContent());
                                obj.put("isRunning", preventionCheckTaskConfig.getIsStartEnd() == 0 ? "1" : "0");
                                obj.put("deleted", "0");
                                obj.put("createDate", LocalDateTimeUtil.format(preventionSecurityRisk.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                                obj.put("createBy", preventionSecurityRisk.getCreateBy());
                                obj.put("updateDate", LocalDateTimeUtil.format(preventionSecurityRisk.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
                                obj.put("updateBy", preventionSecurityRisk.getUpdateBy());
                                data.add(obj);
                            }
                        }
                    }
                }
            }
        }
//        log.error("------------推送隐患排查任务配置-----------------开始");
//        log.error("历史主键：");
//        uuid1.forEach(System.out::println);
//        log.error("最新主键：");
//        uuid2.forEach(System.out::println);
//
//        log.error("--------------");
//
//        log.error("riskMeasureId历史：");
//        uuid3.forEach(System.out::println);
//        log.error("riskMeasureId最新：");
//        uuid4.forEach(System.out::println);
//        log.error("------------推送隐患排查任务配置-----------------结束");

        String url = PreventionConfig.task;
        String s = PreventionConfig.pushData(JSONUtil.toJsonPrettyStr(data), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }


    /**
     * 推送隐患排查任务配置
     *
     * @return
     */
    @GetMapping("/pushTaskConfigJT")
    public AjaxResult pushTaskConfigJT() {
        Map<String, Object> sendMap = new HashMap<>();
        sendMap.put("APPID", "1332");
        sendMap.put("REPORTCOMPANY", "石洞口煤气");
        sendMap.put("REPORTDATE", new DateTime());
        sendMap.put("REPORTMODULE", "AQGL_YHPCRWXX");
        sendMap.put("REPORTTYPE", "双重预防机制");

        List<JSONObject> data = new ArrayList<>();
        List<PreventionDevice> preventionDevices = preventionDeviceMapper.queryAllByLimit(new PreventionDevice());
        for (PreventionDevice preventionDevice : preventionDevices) {
            List<PreventionSecurityRisk> all = preventionSecurityRiskMapper.queryAllUnit(preventionDevice.getId(), getBeginOfDay(), getEndOfDay());
            if (CollUtil.isNotEmpty(all)) {
                for (PreventionSecurityRisk p : all) {
                    String analysisUnit = p.getAnalysisUnit();
                    List<PreventionSecurityRisk> events = preventionSecurityRiskMapper.queryAllEvent(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), analysisUnit);
                    for (PreventionSecurityRisk event : events) {
                        String dangerEvent = event.getDangerEvent();
                        List<PreventionSecurityRisk> controls = preventionSecurityRiskMapper.queryAllControl(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), dangerEvent);
                        for (PreventionSecurityRisk control : controls) {
                            String controlMeasures = control.getControlMeasures();
                            List<PreventionSecurityRisk> list = preventionSecurityRiskMapper.queryAllSecurityRisk(preventionDevice.getId(), getBeginOfDay(), getEndOfDay(), controlMeasures);
                            for (PreventionSecurityRisk preventionSecurityRisk : list) {
                                List<PreventionCheckTaskConfig> preventionCheckTaskConfigs = preventionCheckTaskConfigMapper.querySecurityRiskId(preventionSecurityRisk.getId());
                                if (CollUtil.isEmpty(preventionCheckTaskConfigs)) {
                                    continue;
                                }
                                PreventionCheckTaskConfig preventionCheckTaskConfig = preventionCheckTaskConfigs.get(0);
                                JSONObject obj = new JSONObject();
                                UUID uuid = UUID.randomUUID();
                                String uuidString = uuid.toString();
                                obj.put("ID", uuidString);
                                obj.put("RISKMEASUREID", enId(control.getId().toString()) + "-002");
                                obj.put("COMPANYCODE", GlobalConstants.COMPANY_CODE);

                                obj.put("TROUBLESHOOTCONTENT", preventionSecurityRisk.getHiddenContent());
                                // obj.put("postPersonCharge", preventionSecurityRisk.getDeptUserName());
                                obj.put("CHECKCYCLE", preventionSecurityRisk.getCycle());
                                obj.put("CHECKCYCLEUNIT", preventionSecurityRisk.getUnit().equals("日") ? "天" : preventionSecurityRisk.getUnit());
                                if (preventionSecurityRisk.getUnit().equals("小时")) {
                                    obj.put("WORKSTARTTIME", getWorkTime(preventionCheckTaskConfig.getTaskStartTime()));
                                    obj.put("WORKENDTIME", getWorkTime(preventionCheckTaskConfig.getTaskStartTime()));
                                }
                                obj.put("WORKTYPE", preventionSecurityRisk.getDutyTask().equals("1") ? preventionSecurityRisk.getTaskDuty() : "0");
                                if (!obj.getString("WORKTYPE").equals("0")) {
                                    PreventionTaskNum preventionTaskNum = preventionTaskNumMapper.queryById(preventionSecurityRisk.getTaskNumId());
                                    if (null == preventionTaskNum) {
                                        continue;
                                    }
                                    obj.put("TASKNUM", preventionTaskNum.getTaskNum());
                                }
                                // obj.put("workCalendar", preventionSecurityRisk.getTaskContent());
                                // obj.put("isRunning", preventionCheckTaskConfig.getIsStartEnd() == 0 ? "1" : "0");
                                obj.put("DELETED", "0");
                                obj.put("CREATEDATE", LocalDateTimeUtil.format(preventionSecurityRisk.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                                obj.put("CREATEBY", preventionSecurityRisk.getCreateBy());
                                obj.put("UPDATEDATE", LocalDateTimeUtil.format(preventionSecurityRisk.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
                                obj.put("UPDATEBY", preventionSecurityRisk.getUpdateBy());
                                data.add(obj);
                            }
                        }
                    }
                }
            }
        }

        sendMap.put("REPORTCONTENT", data);
        String url = PreventionConfig.unitJT;
        String s = PreventionConfig.pushDataJT(JSONUtil.toJsonPrettyStr(sendMap), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }


    public String getWorkTime(String time) {
        DateTime parse = DateUtil.parse(time, "yyyy-MM-dd HH:mm:ss");
        String formatTime = DateUtil.formatTime(parse);
        return formatTime;
    }

    public String getWorkType(String userIds) {
        String[] split = userIds.split(",");
        if (split.length > 1) {
            return "0";
        } else {
            return dutyTypeHandler(Long.valueOf(split[0]));
        }
    }

    public String dutyTypeHandler(Long userId) {
        SysDutyUser byUserId = sysDutyUserMapper.getByUserId(userId);
        if (null == byUserId) {
            return "0";
        } else if (byUserId.getDutyType().equals("主要负责人")) {
            return "1";
        } else if (byUserId.getDutyType().equals("技术负责人")) {
            return "2";
        } else if (byUserId.getDutyType().equals("操作负责人")) {
            return "3";
        }
        return "0";
    }

    // TODO 改 mobileMe什么意思

    /**
     * 推送隐患排查任务记录
     *
     * @return
     */
    @GetMapping("/pushTaskRecord")
    public AjaxResult pushTaskRecord(HttpServletRequest request) {
        PreventionCheckTask entity = null;
        PreventionCheckTaskConfig checkTaskConfig = null;

        String beginDay = request.getParameter("begin");
        String endDay = request.getParameter("end");
        beginDay = StringUtils.isEmpty(beginDay) ? getBeginOfDay() : beginDay;
        endDay = StringUtils.isEmpty(endDay) ? getEndOfDay() : endDay;
        List<PreventionCheckTask> list = preventionCheckTaskMapper.queryByTime(beginDay, endDay);
        log.error("日期: {}， 查到需要推送的任务数：{}", beginDay, list.size());
        List<JSONObject> data = new ArrayList<>();

//        List<String> uuid1 = new ArrayList<String>();
//        List<String> uuid2 = new ArrayList<String>();
//
//        List<String> uuid3 = new ArrayList<String>();
//        List<String> uuid4 = new ArrayList<String>();

        for (PreventionCheckTask preventionCheckTask : list) {
            if (preventionCheckTask.getTaskState().equals("待排查") || preventionCheckTask.getTaskState().equals(" ''''")) {
                continue;
            }
            JSONObject obj = new JSONObject();

            String isDefend = "0";
            String createBy = "admin";
            String createByMobile = "13651640262";
            SysUser sysUser = sysUserService.selectUserByNickName(preventionCheckTask.getCheckUserName());
            if (sysUser!=null && sysUser.getUserId()!=null) {
                isDefend = dutyTypeHandler(sysUser.getUserId());
                if (StringUtils.isNotEmpty(sysUser.getPhonenumber())) {
                    createByMobile = sysUser.getPhonenumber();
                }
                createBy = preventionCheckTask.getCheckUserName();
            }

            String governId = preventionCheckTask.getGovernId();
            String uuidString = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
            entity = new PreventionCheckTask();
            entity.setId(preventionCheckTask.getId());
            entity.setGovernId(uuidString);
            preventionCheckTaskMapper.update(entity);
            obj.put("id", uuidString);

            obj.put("companyCode", GlobalConstants.COMPANY_CODE);

//            obj.put("checkTaskId", enId(preventionCheckTask.getCheckTaskConfigId().toString()) + "-003");
            checkTaskConfig = preventionCheckTaskConfigMapper.queryById(preventionCheckTask.getCheckTaskConfigId());
            String governId2 = checkTaskConfig.getGovernId();
            String uuidString2 = StringUtils.isEmpty(governId2) ? UUID.randomUUID().toString() : governId2;
            checkTaskConfig = new PreventionCheckTaskConfig();
            checkTaskConfig.setGovernId(uuidString2);
            checkTaskConfig.setId(preventionCheckTask.getCheckTaskConfigId());
            preventionCheckTaskConfigMapper.update(checkTaskConfig);
            obj.put("checkTaskId", uuidString2);

            obj.put("checkStatus", checkStatus(preventionCheckTask.getCheckResult()));
            obj.put("checkTime", preventionCheckTask.getCheckTime());
            obj.put("deleted", "0");
            obj.put("mobileMe", PreventionConfig.getRandomIMEE(preventionCheckTask.getMobileCode()));
            obj.put("isDefend", isDefend.equals("0") ? "0" : "1");
            obj.put("createDate", LocalDateTimeUtil.format(preventionCheckTask.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("createBy", createBy);
            obj.put("updateDate", LocalDateTimeUtil.format(preventionCheckTask.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("updateBy", "admin");

            obj.put("createByMobile", createByMobile);
            data.add(obj);
        }
//        log.error("------------推送隐患排查任务记录----------------- 开始");
//        log.error("历史主键：");
//        uuid1.forEach(System.out::println);
//        log.error("最新主键：");
//        uuid2.forEach(System.out::println);
//
//        log.error("--------------");
//
//        log.error("checkTaskId历史：");
//        uuid3.forEach(System.out::println);
//        log.error("checkTaskId最新：");
//        uuid4.forEach(System.out::println);
//        log.error("------------推送隐患排查任务记录-----------------结束");

        String url = PreventionConfig.record;
        String s = PreventionConfig.pushData(JSONUtil.toJsonPrettyStr(data), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }

    /**
     * 推送隐患排查任务记录
     *
     * @return
     */
    @GetMapping("/pushTaskRecord2")
    public AjaxResult pushTaskRecord2(HttpServletRequest request) {
        String begin = request.getParameter("begin");

        int i=0;
        String endDay = null;
        String beginDay = null;
        Calendar beginCal = Calendar.getInstance();
        beginCal.setTime(DateUtils.dateTime("yyyy-MM-dd", begin));
        while(i<4) {
            beginDay = DateUtil.format(beginCal.getTime(), "yyyy-MM-dd HH:mm:ss");
            beginCal.add(Calendar.HOUR_OF_DAY, 6);
            endDay = DateUtil.format(beginCal.getTime(), "yyyy-MM-dd HH:mm:ss");
            log.error("开始时间 {}， 结束时间 {}", beginDay, endDay);
            handleTaskRecord(beginDay, endDay);

            i++;
        }
        return AjaxResult.success();
    }

    public void handleTaskRecord(String beginDay, String endDay) {
        List<PreventionCheckTask> list = preventionCheckTaskMapper.queryByTime(beginDay, endDay);
        log.error("日期: {}， 查到需要推送的任务数：{}", beginDay, list.size());
        List<JSONObject> data = new ArrayList<>();


        PreventionCheckTask entity = null;
        PreventionCheckTaskConfig checkTaskConfig = null;

        for (PreventionCheckTask preventionCheckTask : list) {
            if (preventionCheckTask.getTaskState().equals("待排查") || preventionCheckTask.getTaskState().equals(" ''''")) {
                continue;
            }
            JSONObject obj = new JSONObject();

            String isDefend = "0";
            String createBy = "admin";
            String createByMobile = "13651640262";
            SysUser sysUser = sysUserService.selectUserByNickName(preventionCheckTask.getCheckUserName());
            if (sysUser!=null && sysUser.getUserId()!=null) {
                isDefend = dutyTypeHandler(sysUser.getUserId());
                if (StringUtils.isNotEmpty(sysUser.getPhonenumber())) {
                    createByMobile = sysUser.getPhonenumber();
                }
                createBy = preventionCheckTask.getCheckUserName();
            }

            String governId = preventionCheckTask.getGovernId();
            String uuidString = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
            entity = new PreventionCheckTask();
            entity.setId(preventionCheckTask.getId());
            entity.setGovernId(uuidString);
            preventionCheckTaskMapper.update(entity);
            obj.put("id", uuidString);

            obj.put("companyCode", GlobalConstants.COMPANY_CODE);

            checkTaskConfig = preventionCheckTaskConfigMapper.queryById(preventionCheckTask.getCheckTaskConfigId());
            String governId2 = checkTaskConfig.getGovernId();
            String uuidString2 = StringUtils.isEmpty(governId2) ? UUID.randomUUID().toString() : governId2;
            checkTaskConfig = new PreventionCheckTaskConfig();
            checkTaskConfig.setGovernId(uuidString2);
            checkTaskConfig.setId(preventionCheckTask.getCheckTaskConfigId());
            preventionCheckTaskConfigMapper.update(checkTaskConfig);
            obj.put("checkTaskId", uuidString2);

            obj.put("checkStatus", checkStatus(preventionCheckTask.getCheckResult()));
            obj.put("checkTime", preventionCheckTask.getCheckTime());
            obj.put("deleted", "0");
            obj.put("mobileMe", PreventionConfig.getRandomIMEE(preventionCheckTask.getMobileCode()));
            obj.put("isDefend", isDefend.equals("0") ? "0" : "1");
            obj.put("createDate", LocalDateTimeUtil.format(preventionCheckTask.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("createBy", createBy);
            obj.put("updateDate", LocalDateTimeUtil.format(preventionCheckTask.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("updateBy", "admin");

            obj.put("createByMobile", createByMobile);
            data.add(obj);
        }

        String url = PreventionConfig.record;
        String s = PreventionConfig.pushData(JSONUtil.toJsonPrettyStr(data), url);
        pushInfoMapper.insert(s);
    }

    public String checkStatus(String result) {
        if (StrUtil.isEmpty(result)) {
            return "2";
        }
        switch (result) {
            case "正常":
                return "0";
            case "异常":
                return "1";
            default:
                return "3";
        }
    }

    public String checkSrc(String src) {
        if (src.equals("日常排查")) {
            return "1";
        } else if (src.equals("综合性排查")) {
            return "2";
        } else if (src.equals("专业性排查")) {
            return "3";
        } else if (src.equals("季节性排查")) {
            return "4";
        } else if (src.equals("重点时段及节假日前排查")) {
            return "5";
        } else if (src.equals("事故类比排查")) {
            return "6";
        } else if (src.equals("复产复工前排查")) {
            return "7";
        } else if (src.equals("外聘专家诊断式排查")) {
            return "8";
        } else if (src.equals("管控措施实效")) {
            return "9";
        }
        return "10";
    }

    public String checkType(String type) {
        if (type.equals("安全")) {
            return "1";
        } else if (type.equals("工艺")) {
            return "2";
        } else if (type.equals("电气")) {
            return "3";
        } else if (type.equals("仪表")) {
            return "4";
        } else if (type.equals("消防")) {
            return "5";
        } else if (type.equals("总图")) {
            return "6";
        } else if (type.equals("设备")) {
            return "7";
        }
        return "8";
    }

    public String checkState(String state) {
        if (state.equals("待整改")) {
            return "0";
        } else if (state.equals("待复核")) {
            return "1";
        } else if (state.equals("完成")) {
            return "9";
        }
        return null;
    }

    public String checkStateCase(String state) {
        if (state.equals("待整改")) {
            return "0";
        } else if (state.equals("待复核")) {
            return "1";
        } else if (state.equals("已完成")) {
            return "9";
        }
        return null;
    }

    public String checkHiddenLevel(String level) {
        if (level.equals("重大隐患")) {
            return "1";
        }
        return "0";
    }

    /**
     * 查看错误信息
     *
     * @return
     */
    @GetMapping("/errorInfo")
    public AjaxResult errorInfo(@RequestParam("ids") List<String> ids) {
        String url = PreventionConfig.error;
        String result = PreventionConfig.errorInfo(ids, url);
        return AjaxResult.success(result);
    }

    /**
     * 查看推送信息
     *
     * @return
     */
    @GetMapping("/getInfo")
    public AjaxResult getInfo(String batchId) {
        String url = PreventionConfig.getInfo;
        String result = PreventionConfig.getInfo(batchId, url);
        return AjaxResult.success(result);
    }

    public String enId(String id) {

        String a = "qwesdfxcvwerdfgcvber-" + id + "-";

        String a1 = StrUtil.fillAfter(a, 'q', 32);
        return a1;
    }

    public String getBeginOfDay() {
        DateTime date = DateUtil.date();
        //一天的开始，结果：2017-03-01 00:00:00
        String startTime = DateUtil.beginOfDay(date).toString("yyyy-MM-dd HH:mm:ss");
        return startTime;
    }

    public String getEndOfDay() {
        DateTime date = DateUtil.date();
        //一天的结束，结果：2017-03-01 23:59:59
        String endTime = DateUtil.endOfDay(date).toString("yyyy-MM-dd HH:mm:ss");
        return endTime;
    }

    /**
     * 推送隐患信息
     *
     * @return
     */
    @GetMapping("/pushInvestigation")
    public AjaxResult pushInvestigation() {
        PreventionHiddenRegister query = new PreventionHiddenRegister();
        query.setStartTime(getBeginOfDay());
        query.setEndTime(getEndOfDay());
        List<PreventionHiddenRegister> preventionHiddenRegisters = preventionHiddenRegisterMapper.queryPreventionHiddenList(query);
        for (PreventionHiddenRegister preventionHiddenRegister : preventionHiddenRegisters) {
            Integer deviceId = preventionHiddenRegister.getDeviceId();
            PreventionDevice preventionDevice = preventionDeviceMapper.queryById(deviceId);
            SysDanger sysDanger = sysDangerMapper.queryByName(preventionDevice.getDangerName());
            preventionHiddenRegister.setDangerCode(sysDanger.getDangerCode());
            PreventionHiddenInfoRecord preventionHiddenInfoRecord = preventionHiddenInfoRecordMapper.queryHiddenId(preventionHiddenRegister.getId());
            if (null == preventionHiddenInfoRecord || preventionHiddenInfoRecord.getType() != 1) {
                continue;
            }
            Integer preventionCheckTaskConfigId = preventionHiddenInfoRecord.getPreventionCheckTaskConfigId();
            PreventionCheckTaskConfig preventionCheckTaskConfig = preventionCheckTaskConfigMapper.queryById(preventionCheckTaskConfigId);
            PreventionSecurityRisk preventionSecurityRisk = preventionSecurityRiskMapper.queryById(preventionCheckTaskConfig.getSecurityRiskId());
            preventionHiddenRegister.setPreventionHiddenInfoRecord(preventionHiddenInfoRecord);
            preventionHiddenRegister.setSecurityRiskId(preventionSecurityRisk.getId());
            preventionHiddenRegister.setRiskGovernId(preventionSecurityRisk.getGovernId());
            preventionHiddenRegister.setRiskControlGovernId(preventionSecurityRisk.getControlGovernId());
            preventionHiddenRegister.setDeviceId(preventionSecurityRisk.getDeviceId());
            preventionHiddenRegister.setAnalysisUnit(preventionSecurityRisk.getAnalysisUnit());
            preventionHiddenRegister.setDangerEvent(preventionSecurityRisk.getDangerEvent());
            preventionHiddenRegister.setControlMeasures(preventionSecurityRisk.getControlMeasures());
        }

//        List<String> uuid1 = new ArrayList<String>();
//        List<String> uuid2 = new ArrayList<String>();
//
//        List<String> uuid3 = new ArrayList<String>();
//        List<String> uuid4 = new ArrayList<String>();
//
//        List<String> uuid5 = new ArrayList<String>();
//        List<String> uuid6 = new ArrayList<String>();

        PreventionCheckTask checkTask = null;
        PreventionHiddenRegister entity = null;
        PreventionSecurityRisk riskEntity = null;
        List<JSONObject> data = new ArrayList<>();
        for (PreventionHiddenRegister preventionHiddenRegister : preventionHiddenRegisters) {
            String state = checkStateCase(preventionHiddenRegister.getHiddenProgress());
            if (StrUtil.isEmpty(state)) {
                continue;
            }
            JSONObject obj = new JSONObject();

//            obj.put("id", enId(preventionHiddenRegister.getId().toString()) + "-005");
            String governId = preventionHiddenRegister.getGovernId();
            governId = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
            entity = new PreventionHiddenRegister();
            entity.setId(preventionHiddenRegister.getId());
            entity.setGovernId(governId);
            preventionHiddenRegisterMapper.update(entity);
            obj.put("id", governId);

            obj.put("companyCode", GlobalConstants.COMPANY_CODE);
            obj.put("hazardCode", preventionHiddenRegister.getDangerCode());

            if (null != preventionHiddenRegister.getSecurityRiskId()) {
//                obj.put("riskMeasureId", enId(preventionHiddenRegister.getSecurityRiskId().toString()) + "-002");
                String controlGovernId = preventionHiddenRegister.getRiskControlGovernId();
                String uuidString2 = StringUtils.isEmpty(controlGovernId) ? UUID.randomUUID().toString() : controlGovernId;
                riskEntity = new PreventionSecurityRisk();
                riskEntity.setDeviceId(preventionHiddenRegister.getDeviceId());
                riskEntity.setAnalysisUnit(preventionHiddenRegister.getAnalysisUnit());
                riskEntity.setDangerEvent(preventionHiddenRegister.getDangerEvent());
                riskEntity.setControlMeasures(preventionHiddenRegister.getControlMeasures());
                riskEntity.setControlGovernId(uuidString2);
                preventionSecurityRiskMapper.updateGovernId(riskEntity);
                obj.put("riskMeasureId", uuidString2);
            }
            if (null != preventionHiddenRegister.getPreventionHiddenInfoRecord()) {
//                obj.put("checkRecordId", enId(preventionHiddenRegister.getPreventionHiddenInfoRecord().getPreventionCheckTaskId() + "004"));
                Integer checkTaskId = preventionHiddenRegister.getPreventionHiddenInfoRecord().getPreventionCheckTaskId();
                checkTask = preventionCheckTaskMapper.queryById(checkTaskId);
                String taskGovernId = checkTask.getGovernId();
                String uuidString3 = StringUtils.isEmpty(taskGovernId) ? UUID.randomUUID().toString() : taskGovernId;
                checkTask = new PreventionCheckTask();
                checkTask.setGovernId(uuidString3);
                checkTask.setId(checkTaskId);
                preventionCheckTaskMapper.update(checkTask);
                obj.put("checkRecordId", uuidString3);
            }

            obj.put("dangerName", preventionHiddenRegister.getHiddenName());
            obj.put("dangerLevel", checkHiddenLevel(preventionHiddenRegister.getHiddenLevel()));
            obj.put("dangerSrc", checkSrc(preventionHiddenRegister.getHiddenCheckType()));
            obj.put("dangerManageType", "1");
            obj.put("dangerDesc", preventionHiddenRegister.getHiddenInfo());
            obj.put("dangerReason", preventionHiddenRegister.getHiddenEntryBasis());
            obj.put("controlMeasures", preventionHiddenRegister.getHiddenRectificationMeasures());
            obj.put("cost", preventionHiddenRegister.getHiddenManagingFunds());
            obj.put("dangerManageDeadline", preventionHiddenRegister.getRectificationEndTime());
            obj.put("dangerState", state);
            obj.put("hazardDangerType", checkType(preventionHiddenRegister.getHiddenType()));
            obj.put("registrant", preventionHiddenRegister.getRegisterUserName());
            obj.put("registTime", preventionHiddenRegister.getHiddenCheckTime());
            obj.put("liablePerson", preventionHiddenRegister.getRectificationUserName());
            obj.put("checkAcceptPerson", preventionHiddenRegister.getReviewUserName());
            obj.put("checkAcceptComment", preventionHiddenRegister.getHiddenReviewInfo());
            obj.put("checkAcceptTime", preventionHiddenRegister.getHiddenReviewTime());
            obj.put("deleted", "0");
            obj.put("createDate", LocalDateTimeUtil.format(preventionHiddenRegister.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("createBy", preventionHiddenRegister.getRegisterUserName());
            obj.put("updateDate", LocalDateTimeUtil.format(preventionHiddenRegister.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("updateBy", preventionHiddenRegister.getRegisterUserName());
            //hazardCategory
            obj.put("hazardCategory", getWorkType(preventionHiddenRegister.getRegisterUserId().toString()));
            data.add(obj);
        }

//        log.error("------------推送隐患信息-----------------开始");
//        log.error("历史主键：");
//        uuid1.forEach(System.out::println);
//        log.error("最新主键：");
//        uuid2.forEach(System.out::println);
//
//        log.error("--------------");
//
//        log.error("riskMeasureId历史：");
//        uuid3.forEach(System.out::println);
//        log.error("riskMeasureId最新：");
//        uuid4.forEach(System.out::println);
//
//        log.error("--------------");
//
//        log.error("checkRecordId历史：");
//        uuid5.forEach(System.out::println);
//        log.error("checkRecordId最新：");
//        uuid6.forEach(System.out::println);
//        log.error("------------推送隐患信息-----------------结束");

        String url = PreventionConfig.investigation;
        String s = PreventionConfig.pushData(JSONUtil.toJsonPrettyStr(data), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }

    /**
     * 定时任务推送隐患信息
     *
     * @return
     */
    public AjaxResult pushInvestigationNew() {
        PreventionHiddenRegister query = new PreventionHiddenRegister();
        query.setStartTime(getBeginOfDay());
        query.setEndTime(getEndOfDay());
        List<PreventionHiddenRegister> preventionHiddenRegisters = preventionHiddenRegisterMapper.queryPreventionHiddenList(query);
        for (PreventionHiddenRegister preventionHiddenRegister : preventionHiddenRegisters) {
            Integer deviceId = preventionHiddenRegister.getDeviceId();
            PreventionDevice preventionDevice = preventionDeviceMapper.queryById(deviceId);
            SysDanger sysDanger = sysDangerMapper.queryByName(preventionDevice.getDangerName());
            preventionHiddenRegister.setDangerCode(sysDanger.getDangerCode());
            PreventionHiddenInfoRecord preventionHiddenInfoRecord = preventionHiddenInfoRecordMapper.queryHiddenId(preventionHiddenRegister.getId());
            if (null == preventionHiddenInfoRecord || preventionHiddenInfoRecord.getType() != 1) {
                continue;
            }
            Integer preventionCheckTaskConfigId = preventionHiddenInfoRecord.getPreventionCheckTaskConfigId();
            PreventionCheckTaskConfig preventionCheckTaskConfig = preventionCheckTaskConfigMapper.queryById(preventionCheckTaskConfigId);
            PreventionSecurityRisk preventionSecurityRisk = preventionSecurityRiskMapper.queryById(preventionCheckTaskConfig.getSecurityRiskId());
            preventionHiddenRegister.setPreventionHiddenInfoRecord(preventionHiddenInfoRecord);
            preventionHiddenRegister.setSecurityRiskId(preventionSecurityRisk.getId());
            preventionHiddenRegister.setRiskGovernId(preventionSecurityRisk.getGovernId());
            preventionHiddenRegister.setRiskControlGovernId(preventionSecurityRisk.getControlGovernId());
            preventionHiddenRegister.setDeviceId(preventionSecurityRisk.getDeviceId());
            preventionHiddenRegister.setAnalysisUnit(preventionSecurityRisk.getAnalysisUnit());
            preventionHiddenRegister.setDangerEvent(preventionSecurityRisk.getDangerEvent());
            preventionHiddenRegister.setControlMeasures(preventionSecurityRisk.getControlMeasures());
        }

        PreventionCheckTask checkTask = null;
        PreventionHiddenRegister entity = null;
        PreventionSecurityRisk riskEntity = null;
        List<JSONObject> data = new ArrayList<>();
        for (PreventionHiddenRegister preventionHiddenRegister : preventionHiddenRegisters) {
            String state = checkStateCase(preventionHiddenRegister.getHiddenProgress());
            if (StrUtil.isEmpty(state)) {
                continue;
            }

            JSONObject obj = new JSONObject();
//            obj.put("id", enId(preventionHiddenRegister.getId().toString()) + "-005");
            String governId = preventionHiddenRegister.getGovernId();
            String uuidString = StringUtils.isEmpty(governId) ? UUID.randomUUID().toString() : governId;
            entity = new PreventionHiddenRegister();
            entity.setId(preventionHiddenRegister.getId());
            entity.setGovernId(uuidString);
            preventionHiddenRegisterMapper.update(entity);
            obj.put("id", uuidString);

            obj.put("companyCode", GlobalConstants.COMPANY_CODE);
            obj.put("hazardCode", preventionHiddenRegister.getDangerCode());
            if (null != preventionHiddenRegister.getSecurityRiskId()) {
//                obj.put("riskMeasureId", enId(preventionHiddenRegister.getSecurityRiskId().toString()) + "-002");
                String controlGovernId = preventionHiddenRegister.getRiskControlGovernId();
                String uuidString2 = StringUtils.isEmpty(controlGovernId) ? UUID.randomUUID().toString() : controlGovernId;
                riskEntity = new PreventionSecurityRisk();
                riskEntity.setDeviceId(preventionHiddenRegister.getDeviceId());
                riskEntity.setAnalysisUnit(preventionHiddenRegister.getAnalysisUnit());
                riskEntity.setDangerEvent(preventionHiddenRegister.getDangerEvent());
                riskEntity.setControlMeasures(preventionHiddenRegister.getControlMeasures());
                riskEntity.setControlGovernId(uuidString2);
                preventionSecurityRiskMapper.updateGovernId(riskEntity);
                obj.put("riskMeasureId", uuidString2);
            }
            if (null != preventionHiddenRegister.getPreventionHiddenInfoRecord()) {
//                obj.put("checkRecordId", enId(preventionHiddenRegister.getPreventionHiddenInfoRecord().getPreventionCheckTaskId() + "004"));
                Integer checkTaskId = preventionHiddenRegister.getPreventionHiddenInfoRecord().getPreventionCheckTaskId();
                checkTask = preventionCheckTaskMapper.queryById(checkTaskId);
                String taskGovernId = checkTask.getGovernId();
                String uuidString3 = StringUtils.isEmpty(taskGovernId) ? UUID.randomUUID().toString() : taskGovernId;
                checkTask = new PreventionCheckTask();
                checkTask.setGovernId(uuidString3);
                checkTask.setId(checkTaskId);
                preventionCheckTaskMapper.update(checkTask);
                obj.put("checkRecordId", uuidString3);
            }

            obj.put("dangerName", preventionHiddenRegister.getHiddenName());
            obj.put("dangerLevel", checkHiddenLevel(preventionHiddenRegister.getHiddenLevel()));
            obj.put("dangerSrc", checkSrc(preventionHiddenRegister.getHiddenCheckType()));
            obj.put("dangerManageType", "1");
            obj.put("dangerDesc", preventionHiddenRegister.getHiddenInfo());
            obj.put("dangerReason", preventionHiddenRegister.getHiddenEntryBasis());
            obj.put("controlMeasures", preventionHiddenRegister.getHiddenRectificationMeasures());
            obj.put("cost", preventionHiddenRegister.getHiddenManagingFunds());
            obj.put("dangerManageDeadline", preventionHiddenRegister.getRectificationEndTime());
            obj.put("dangerState", state);
            obj.put("hazardDangerType", checkType(preventionHiddenRegister.getHiddenType()));
            obj.put("registrant", preventionHiddenRegister.getRegisterUserName());
            obj.put("registTime", preventionHiddenRegister.getHiddenCheckTime());
            obj.put("liablePerson", preventionHiddenRegister.getRectificationUserName());
            obj.put("checkAcceptPerson", preventionHiddenRegister.getReviewUserName());
            obj.put("checkAcceptComment", preventionHiddenRegister.getHiddenReviewInfo());
            obj.put("checkAcceptTime", preventionHiddenRegister.getHiddenReviewTime());
            obj.put("deleted", "0");
            obj.put("createDate", LocalDateTimeUtil.format(preventionHiddenRegister.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("createBy", preventionHiddenRegister.getRegisterUserName());
            obj.put("updateDate", LocalDateTimeUtil.format(preventionHiddenRegister.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("updateBy", preventionHiddenRegister.getRegisterUserName());
            //hazardCategory
            obj.put("hazardCategory", getWorkType(preventionHiddenRegister.getRegisterUserId().toString()));
            data.add(obj);
        }
        String url = PreventionConfig.investigation;
        String s = PreventionConfig.pushData(JSONUtil.toJsonPrettyStr(data), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }


    @GetMapping("pushInvestigationNewJT")
    public AjaxResult pushInvestigationNewJT() {
        PreventionHiddenRegister query = new PreventionHiddenRegister();
        query.setStartTime(getBeginOfDay());
        query.setEndTime(getEndOfDay());
        List<PreventionHiddenRegister> preventionHiddenRegisters = preventionHiddenRegisterMapper.queryPreventionHiddenList(query);

        Map<String, Object> sendMap = new HashMap<>();
        sendMap.put("APPID", "1332");
        sendMap.put("REPORTCOMPANY", "石洞口煤气");
        sendMap.put("REPORTDATE", new DateTime());
        sendMap.put("REPORTMODULE", "AQGL_YHXX");
        sendMap.put("REPORTTYPE", "双重预防机制");

        for (PreventionHiddenRegister preventionHiddenRegister : preventionHiddenRegisters) {
            Integer deviceId = preventionHiddenRegister.getDeviceId();
            PreventionDevice preventionDevice = preventionDeviceMapper.queryById(deviceId);
            SysDanger sysDanger = sysDangerMapper.queryByName(preventionDevice.getDangerName());
            preventionHiddenRegister.setDangerCode(sysDanger.getDangerCode());
            PreventionHiddenInfoRecord preventionHiddenInfoRecord = preventionHiddenInfoRecordMapper.queryHiddenId(preventionHiddenRegister.getId());
            if (null == preventionHiddenInfoRecord || preventionHiddenInfoRecord.getType() != 1) {
                continue;
            }
            Integer preventionCheckTaskConfigId = preventionHiddenInfoRecord.getPreventionCheckTaskConfigId();
            PreventionCheckTaskConfig preventionCheckTaskConfig = preventionCheckTaskConfigMapper.queryById(preventionCheckTaskConfigId);
            PreventionSecurityRisk preventionSecurityRisk = preventionSecurityRiskMapper.queryById(preventionCheckTaskConfig.getSecurityRiskId());
            preventionHiddenRegister.setPreventionHiddenInfoRecord(preventionHiddenInfoRecord);
            preventionHiddenRegister.setSecurityRiskId(preventionSecurityRisk.getId());
        }

        List<JSONObject> data = new ArrayList<>();
        for (PreventionHiddenRegister preventionHiddenRegister : preventionHiddenRegisters) {
            String state = checkStateCase(preventionHiddenRegister.getHiddenProgress());
            if (StrUtil.isEmpty(state)) {
                continue;
            }
            JSONObject obj = new JSONObject();
            UUID uuid = UUID.randomUUID();
            String uuidString = uuid.toString();
            obj.put("ID", uuidString);
            obj.put("HAZARDCODE", preventionHiddenRegister.getDangerCode());
            obj.put("COMPANYCODE", GlobalConstants.COMPANY_CODE);
            if (null != preventionHiddenRegister.getSecurityRiskId()) {
                obj.put("RISKMEASUREID", enId(preventionHiddenRegister.getSecurityRiskId().toString()) + "-002");
            }
            if (null != preventionHiddenRegister.getPreventionHiddenInfoRecord()) {
                obj.put("CHECKRECORDID", enId(preventionHiddenRegister.getPreventionHiddenInfoRecord().getPreventionCheckTaskId() + "004"));
            }
            obj.put("DANGERNAME", preventionHiddenRegister.getHiddenName());
            obj.put("DANGERLEVEL", checkHiddenLevel(preventionHiddenRegister.getHiddenLevel()));
            obj.put("DANGERSRC", checkSrc(preventionHiddenRegister.getHiddenCheckType()));
            obj.put("DANGERMANAGETYPE", "1");
            obj.put("DANGERDESC", preventionHiddenRegister.getHiddenInfo());
            obj.put("DANGERREASON", preventionHiddenRegister.getHiddenEntryBasis());
            obj.put("CONTROLMEASURES", preventionHiddenRegister.getHiddenRectificationMeasures());
            obj.put("COST", preventionHiddenRegister.getHiddenManagingFunds());
            obj.put("DANGERMANAGEDEADLINE", preventionHiddenRegister.getRectificationEndTime());
            obj.put("DANGERSTATE", state);
            obj.put("HAZARDDANGERTYPE", checkType(preventionHiddenRegister.getHiddenType()));
            obj.put("REGISTRANT", preventionHiddenRegister.getRegisterUserName());
            obj.put("REGISTTIME", preventionHiddenRegister.getHiddenCheckTime());
            obj.put("LIABLEPERSON", preventionHiddenRegister.getRectificationUserName());
            obj.put("CHECKACCEPTPERSON", preventionHiddenRegister.getReviewUserName());
            obj.put("CHECKACCEPTCOMMENT", preventionHiddenRegister.getHiddenReviewInfo());
            obj.put("CHECKACCEPTTIME", preventionHiddenRegister.getHiddenReviewTime());
            obj.put("DELETED", "0");
            obj.put("CREATEDATE", LocalDateTimeUtil.format(preventionHiddenRegister.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("CREATEBY", preventionHiddenRegister.getRegisterUserName());
            obj.put("UPDATEDATE", LocalDateTimeUtil.format(preventionHiddenRegister.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("UPDATEBY", preventionHiddenRegister.getRegisterUserName());
            //hazardCategory
            obj.put("HAZARDCATEGORY", getWorkType(preventionHiddenRegister.getRegisterUserId().toString()));
            data.add(obj);
        }
        sendMap.put("REPORTCONTENT", data);

        String url = PreventionConfig.unitJT;
        String s = PreventionConfig.pushDataJT(JSONUtil.toJsonPrettyStr(sendMap), url);
        pushInfoMapper.insert(s);
        return AjaxResult.success();
    }

    /**
     * 定时推送 1天  安全风险分析单元-安全风险事件-安全风险管控措施-隐患排查任务
     */
    @Scheduled(cron = "0 0 23 * * ?")
    public void pushOneDay() {
        pushUnit();
        pushEvent();
        pushControl();
        pushTaskConfig();
        pushUnitStop();
        pushInvestigationNew();
    }

    /**
     * 定时推送 1天  安全风险分析单元-安全风险事件-安全风险管控措施-隐患排查任务
     */
    @Scheduled(cron = "0 0 23 * * ?")
    public void pushOneDayJT() {
        pushUnitJT();
        pushEventJT();
        pushControlJT();
        pushTaskConfigJT();
        pushUnitStopJT();
        pushInvestigationNewJT();
    }

    @Scheduled(cron = "0 55 23 * * ?")
    public void pushRecord() {
        pushTaskRecordHandler();
    }

    /**
     * 定时推送 1小时  隐患排查记录
     */
    @Scheduled(cron = "0 0 0/1 * * ?")
    public void pushOneHour() {
        pushTaskRecordHandler();
    }

    public void pushTaskRecordHandler() {
        DateTime date = DateUtil.date();

        //一天的开始，结果：2017-03-01 00:00:00
        String startTime = DateUtil.beginOfDay(date).toString("yyyy-MM-dd HH:mm:ss");
        //一天的结束，结果：2017-03-01 23:59:59
        String endTime = DateUtil.endOfDay(date).toString("yyyy-MM-dd HH:mm:ss");
        List<PreventionCheckTask> list = preventionCheckTaskMapper.queryByTime(startTime, endTime);
        List<JSONObject> data = new ArrayList<>();

        PreventionCheckTask taskEntity = null;
        PreventionCheckTaskConfig config = null;

        for (PreventionCheckTask preventionCheckTask : list) {
            if (preventionCheckTask.getTaskState().equals("待排查") || preventionCheckTask.getTaskState().equals("已超时")) {
                continue;
            }

            String isDefend = "0";
            String createBy = "admin";
            String createByMobile = "13651640262";
            SysUser sysUser = sysUserService.selectUserByNickName(preventionCheckTask.getCheckUserName());
            if (sysUser!=null && sysUser.getUserId()!=null) {
                isDefend = dutyTypeHandler(sysUser.getUserId());
                if (StringUtils.isNotEmpty(sysUser.getPhonenumber())) {
                    createByMobile = sysUser.getPhonenumber();
                }
                createBy = preventionCheckTask.getCheckUserName();
            }

            JSONObject obj = new JSONObject();
            String taskGovernId = preventionCheckTask.getGovernId();
            String uuidString = StringUtils.isEmpty(taskGovernId) ? UUID.randomUUID().toString() : taskGovernId;
            taskEntity = new PreventionCheckTask();
            taskEntity.setGovernId(uuidString);
            taskEntity.setId(preventionCheckTask.getId());
            preventionCheckTaskMapper.update(taskEntity);
            obj.put("id", uuidString);

            obj.put("companyCode", GlobalConstants.COMPANY_CODE);

            config = preventionCheckTaskConfigMapper.queryById(preventionCheckTask.getCheckTaskConfigId());
            String configGovernId = config.getGovernId();
            String uuidString2 = StringUtils.isEmpty(configGovernId) ? UUID.randomUUID().toString() : configGovernId;
            config = new PreventionCheckTaskConfig();
            config.setGovernId(uuidString2);
            config.setId(preventionCheckTask.getCheckTaskConfigId());
            preventionCheckTaskConfigMapper.update(config);
            obj.put("checkTaskId", uuidString2);

            obj.put("checkStatus", checkStatus(preventionCheckTask.getCheckResult()));
            obj.put("checkTime", preventionCheckTask.getCheckTime());
            obj.put("deleted", "0");
            obj.put("mobileMe", PreventionConfig.getRandomIMEE(preventionCheckTask.getMobileCode()));
            obj.put("isDefend", isDefend.equals("0") ? "0" : "1");
            obj.put("createDate", LocalDateTimeUtil.format(preventionCheckTask.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("createBy", createBy);
            obj.put("updateDate", LocalDateTimeUtil.format(preventionCheckTask.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("updateBy", "admin");
            obj.put("createByMobile", createByMobile);

            data.add(obj);
        }
        String url = PreventionConfig.record;
        String s = PreventionConfig.pushData(JSONUtil.toJsonPrettyStr(data), url);
        pushInfoMapper.insert(s);
    }

    @GetMapping("/pushOneHourJT")
    @Scheduled(cron = "0 0 0/1 * * ?")
    public void pushOneHourJT() {
//        log.info("申能集团推送， 双重预防机制 +++++++++++++++++++++++++");
        Map<String, Object> sendMap = new HashMap<>();
        sendMap.put("APPID", "1332");
        sendMap.put("REPORTCOMPANY", "石洞口煤气");
        sendMap.put("REPORTDATE", new DateTime());
        sendMap.put("REPORTMODULE", "AQGL_YHPCJL");
        sendMap.put("REPORTTYPE", "双重预防机制");

//        DateTime date = DateUtil.date();
//        //一天的开始，结果：2017-03-01 00:00:00
//        String startTime = DateUtil.beginOfDay(date).toString("yyyy-MM-dd HH:mm:ss");
//        //一天的结束，结果：2017-03-01 23:59:59
//        String endTime = DateUtil.endOfDay(date).toString("yyyy-MM-dd HH:mm:ss");

        // 获取当前日期和时间
        Calendar calendar = Calendar.getInstance();
        // 减去一个小时
        calendar.add(Calendar.HOUR_OF_DAY, -1);
        // 输出结果
        Date date = calendar.getTime();
        String date_hour = DateUtils.parseDateToStr("yyyy-MM-dd HH", date);
        String startTime = date_hour + ":00:00";
        String endTime = date_hour + ":59:59";

        List<PreventionCheckTask> list = preventionCheckTaskMapper.queryByTime(startTime, endTime);
//        log.info("申能集团推送， 双重预防机制-数目 ：" + list.size());
        List<JSONObject> data = new ArrayList<>();
        for (PreventionCheckTask preventionCheckTask : list) {
            if (preventionCheckTask.getTaskState().equals("待排查") || preventionCheckTask.getTaskState().equals("已超时")) {
                continue;
            }

            String isDefend = "0";
            SysUser sysUser = sysUserService.selectUserByNickName(preventionCheckTask.getCheckUserName());
            if (sysUser!=null && sysUser.getUserId()!=null) {
                isDefend = dutyTypeHandler(sysUser.getUserId());
            }

            JSONObject obj = new JSONObject();
            UUID uuid = UUID.randomUUID();
            String uuidString = uuid.toString();
            obj.put("ID", uuidString);
            obj.put("CHECKTASKID", enId(preventionCheckTask.getCheckTaskConfigId().toString()) + "-003");
            obj.put("COMPANYCODE", GlobalConstants.COMPANY_CODE);
            obj.put("CHECKSTATUS", checkStatus(preventionCheckTask.getCheckResult()));
            obj.put("CHECKTIME", preventionCheckTask.getCheckTime());
            obj.put("DELETED", "0");
            obj.put("MOBILEME", PreventionConfig.getRandomIMEE(preventionCheckTask.getMobileCode()));
            obj.put("ISDEFEND", isDefend.equals("0") ? "0" : "1");
            obj.put("CREATEDATE", LocalDateTimeUtil.format(preventionCheckTask.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("CREATEBY", "admin");
            obj.put("UPDATEDATE", LocalDateTimeUtil.format(preventionCheckTask.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
            obj.put("UPDATEBY", "admin");
            data.add(obj);
//            log.info("申能集团推送， 双重预防机制-数据 ：" + obj.toString());
        }
        sendMap.put("REPORTCONTENT", data);

        String url = PreventionConfig.unitJT;
        String s = PreventionConfig.pushDataJT(JSONUtil.toJsonPrettyStr(sendMap), url);
        pushInfoMapper.insert(s);
    }


    @GetMapping
    public void check() {

        PreventionSecurityRisk preventionSecurityRisk = preventionSecurityRiskMapper.queryById(1266);
        String controlMeasures = preventionSecurityRisk.getControlMeasures();
        System.out.println(controlMeasures);
        System.out.println(controlMeasures.equals(controlMeasures));
        PreventionSecurityRisk preventionSecurityRisk1 = new PreventionSecurityRisk();
        preventionSecurityRisk1.setControlMeasures(controlMeasures);
        List<PreventionSecurityRisk> preventionSecurityRiskList = preventionSecurityRiskMapper.queryAllByLimit(preventionSecurityRisk1);
        System.out.println(JSONUtil.toJsonPrettyStr(preventionSecurityRiskList));

    }

    @GetMapping("pushDangerPoint")
    @Scheduled(cron = "0 0 0/2 * * ?")
    public AjaxResult pushDangerPoint() {
        Map<String, Object> sendMap = new HashMap<>();
        sendMap.put("app_id", "1332");
        sendMap.put("report_company", "石洞口煤气");
        sendMap.put("report_date", LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss"));
        sendMap.put("report_module", "监测指标信息表");

        List<JSONObject> data = new ArrayList<>();

        SysDangerPoint sysDangerPointReq = new SysDangerPoint();
        List<SysDangerPoint> sysDangerPoints = this.sysDangerPointService.queryByPage(sysDangerPointReq);
        Map<String, Object> map = ExampleBase.toResult();
        if (CollUtil.isNotEmpty(map)) {
            sysDangerPoints.forEach(sysDangerPoint -> {
                if (map.containsKey(sysDangerPoint.getBitNumber())) {
                    Object o = map.get(sysDangerPoint.getBitNumber());
                    if (o!=null && compare(o.toString())) {
                        sysDangerPoint.setAv("0.000");
                    } else {
                        assert o != null;
                        sysDangerPoint.setAv(o.toString());
                    }
                }
            });
        }

        if (CollectionUtils.isEmpty(sysDangerPoints)) {
            return AjaxResult.success();
        }

        for (SysDangerPoint sysDangerPoint : sysDangerPoints) {
            JSONObject obj = new JSONObject();
            obj.put("zbmc", sysDangerPoint.getParam());
            if (sysDangerPoint.getParam().equals("温度")) {
                obj.put("zblx", "WD");
            } else {
                obj.put("zblx", "YW");
            }
            obj.put("Jldw", sysDangerPoint.getUnit());
            obj.put("zbms", sysDangerPoint.getPointInfo());
            obj.put("yjfzsx", sysDangerPoint.getHighAndMighty());
            obj.put("ejfzsx", sysDangerPoint.getHighQuota());
            obj.put("yjfzxx", sysDangerPoint.getLowQuota());
            obj.put("ejfzxx", sysDangerPoint.getPlayItLow());
            obj.put("lcsx", sysDangerPoint.getDangerRange());
            obj.put("lcxx", sysDangerPoint.getDangerRange());
            obj.put("sssj", sysDangerPoint.getAv());
            data.add(obj);
        }

        sendMap.put("report_content", data);

        String url = PreventionConfig.secureJT;
        String s = PreventionConfig.pushDataJT(JSONUtil.toJsonPrettyStr(sendMap), url);
        pushInfoMapper.insert(s);

        return AjaxResult.success();
    }

    public static boolean compare(String decimal) {
        BigDecimal bd1 = new BigDecimal(decimal);
        BigDecimal bd2 = new BigDecimal(25);
        return bd1.compareTo(bd2) >= 0;
    }


    public static void dopush(List<JSONObject> data) {
        String url = PreventionConfig.investigation;
        String s = PreventionConfig.pushData(JSONUtil.toJsonPrettyStr(data), url);
        System.out.println(s);
    }

    public static JSONObject pushDelete2(String id) {
        JSONObject obj = new JSONObject();
        obj.put("id", id);
        obj.put("companyCode", GlobalConstants.COMPANY_CODE);
        obj.put("hazardCode", "310170003010");
        obj.put("dangerName", "2号柴油消防泵启动马达损坏、飞轮齿损坏");
        obj.put("dangerLevel", "0");
        obj.put("dangerSrc", "10");
        obj.put("dangerManageType", "1");
        obj.put("dangerDesc", "2号柴油泵启动马达故障，造成飞轮齿损坏。");
        obj.put("dangerReason", "马达故障");
        obj.put("controlMeasures", "更换启动马达和飞轮");
        obj.put("dangerManageDeadline", "2025-07-04 16:00:00");
        obj.put("dangerState", "0");
        obj.put("hazardDangerType", "5");
        obj.put("registrant", "wangjian");
        obj.put("registTime", "2025-06-30 07:54:17");
        obj.put("liablePerson", "王健");
        obj.put("checkAcceptPerson", "顾士家");
        obj.put("deleted", "1");
        obj.put("createDate", "2025-07-01 08:00:30");
        obj.put("createBy", "wangjian");
        obj.put("updateDate", "2025-07-01 08:25:03");
        obj.put("updateBy", "wangjian");
        obj.put("hazardCategory", "0");

        return obj;
    }

    public static void pushDelete() throws IOException {
//        List<String> ids = FileUtils.readLines(new File("D:/program/WeChat/data log/WeChat Files/wxid_zm3zbkbw1yo22/FileStorage/File/2025-05/uuid1.txt"), "UTF-8");

//        int i = 0;
        List<JSONObject> data = new ArrayList<>();
//        for (String id : ids) {
//            i++;
//            JSONObject obj = pushDelete2(id);
//            data.add(obj);
//            if (i%100==0) {
//                dopush(data);
//                data.clear();
//            }
//        }
        JSONObject obj = pushDelete2("29aadf9d-471a-4622-89b8-2273a3ff0d69");
        data.add(obj);
        dopush(data);
    }

    public static void main(String[] args) {
        try {
            pushDelete();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}
